package com.pyb.java.basemodule;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * dexc : 适配器基类
 */

public abstract class BaseAdapter<T> extends BaseQuickAdapter<T, BaseViewHolder>
        implements BaseQuickAdapter.OnItemClickListener,
        BaseQuickAdapter.OnItemChildClickListener{
    private Context context;

    public Context getContext() {
        return context;
    }

    protected LayoutInflater inflater;

    public BaseAdapter(Context context, int layoutResId, @Nullable List data) {
        this(context, layoutResId, data, false, false);
    }

    public BaseAdapter(Context context, int layoutResId, @Nullable List data, boolean setEmptyView, boolean setfooterView) {
        super(layoutResId, data);
        this.context = context;
        inflater = LayoutInflater.from(context);
        if (setEmptyView) {
            View emptyView = inflater.inflate(R.layout.module_layout_list_empty, null);
            setEmptyView(emptyView);
        }
        if (setfooterView) {
            View footerView = inflater.inflate(R.layout.module_layout_list_footer, null);
            setFooterView(footerView);
        }

        setOnItemClickListener(this);
        setOnItemChildClickListener(this);
    }

    public void setNoMore() {
        View footerView = inflater.inflate(R.layout.module_layout_list_footer, null);
        setFooterView(footerView);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
    }


    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
    }


}
